package dao.impl;

import dao.IOrderDAO;
import model.Orders;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

public class OrderDAO implements IOrderDAO {

    //	private SessionFactory sessionFactory;
    private SessionFactory sessionFacory;

    public SessionFactory getSessionFacory() {
        return getSessionFacory();
    }

    public void setSessionFacory(SessionFactory sessionFactory) {
        this.sessionFacory = sessionFactory;
    }

    public Orders saveOrder(Orders order) {
        Session session = sessionFacory.openSession();
        Transaction ts = session.beginTransaction();
        session.save(order);
        ts.commit();
        session.close();
        return order;
    }

}
